<%@page contentType="text/html; charset=utf8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<%
	//定义全局变量
	String path = request.getContextPath();
%>
<head>
    <title>用户</title> 
    <link href="<%=path%>/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="<%=path%>/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <script src="<%=path%>/lib/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="<%=path%>/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script>   
    <link href="<%=path%>/lib/css/common.css" rel="stylesheet" type="text/css" />  
    <script src="<%=path%>/lib/js/common.js" type="text/javascript"></script>   
    <script src="<%=path%>/lib/js/LG.js" type="text/javascript"></script>
    <script src="<%=path%>/lib/js/ligerui.expand.js" type="text/javascript"></script> 
    <script src="<%=path%>/lib/json2.js" type="text/javascript"></script>
</head>
<body style="padding:10px;height:100%; text-align:center;">
  <input type="hidden" id="MenuNo" value="MemberManageUser" />
  <div id="mainsearch" style=" width:98%">
    <div class="searchtitle">
        <span>搜索</span><img src="<%=path%>/lib/icons/32X32/searchtool.gif" />
        <div class="togglebtn"></div> 
    </div>
    <div class="navline" style="margin-bottom:4px; margin-top:4px;"></div>
    <div class="searchbox">
        <form id="formsearch" class="l-form"></form> 
    </div>
  </div>
  <div id="maingrid"></div> 
  <script type="text/javascript">
      //列表结构
      var grid = $("#maingrid").ligerGrid({
          columns: [
          { display: "用户名", name: "username", width: 180, type: "text", align: "left" }, 
          { display: "昵称", name: "nickname", width: 180, type: "text", align: "left" },
          { display: "电话", name: "tel", width: 180, type: "text", align: "left" }, 
          { display: "电子邮件", name: "email", width: 180, type: "text", align: "left" }, 
          { display: "机构", name: "departmentid", width: 180, type: "text", align: "left" },
          { display: "区域", name: "areaid", width: 180, type: "text", align: "left" },
          { display: "备注", name: "remark", width: 180, type: "textarea", align: "left" }   
          ], dataAction: 'server', pageSize: 20, toolbar: {},
          url: '<%=path%>/appsystem/user!Grid.do', sortName: 'UserID', 
          width: '98%', height: '100%',heightDiff:-10, checkbox: false
      });

        //双击事件
      LG.setGridDoubleClick(grid, 'modify');

      //搜索表单应用ligerui样式
      $("#formsearch").ligerForm({
		   fields:[],
		   appendID:false,
		   toJSON: JSON2.stringify 
	  });

      //增加搜索按钮,并创建事件
      LG.appendSearchButtons("#formsearch", grid);

      //加载toolbar
      LG.loadToolbar(grid, toolbarBtnItemClick);

      //工具条事件
      function toolbarBtnItemClick(item) {
          switch (item.id) {
              case "add":
                  top.f_addTab(null, '增加用户信息', '<%=path%>/appsystem/user!Listadd.do');
                  break;
              case "view":
                  var selected = grid.getSelected();
                  if (!selected) { LG.tip('请选择行!'); return }
                  top.f_addTab(null, '查看用户信息', '<%=path%>/appsystem/user!Listdetail.do?search.pid=' + selected.UserID);
                  break;
              case "modify":
                  var selected = grid.getSelected();
                  if (!selected) { LG.tip('请选择行!'); return }
                  top.f_addTab(null, '修改用户信息', '<%=path%>/appsystem/user!Listedit.do?search.pid=' + selected.UserID);
                  break;
              case "delete":
                  jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
                      if (confirm)
                          f_delete();
                  });
                  break;
          }
      }
      function f_reload() {
          grid.loadData();
      }
      function f_delete() {
          var selected = grid.getSelected();
          if (selected) {
          		var url = '/user!Delete.do';
				$.ajax({cache:false, async:true, url:url, 
						data:[{ name: 'search.pid', value: MenuNo }], 
						dataType:"json", type:"post",
				beforeSend:function () {
					LG.loading = true;
					LG.showLoading("正在删除中...");
				}, complete:function () {
					LG.loading = false;
					LG.hideLoading();
				}, success:function (result) {
					if (!result) {
						return;
					}
					if (!result.isError) {
						LG.showSuccess('删除成功');
                        f_reload();
					} else {
						LG.tip("\u53d1\u73b0\u7cfb\u7edf\u9519\u8bef <BR>\u9519\u8bef\u7801\uff1a" + result.message);
					}
				}});
          }
          else {
              LG.tip('请选择行!');
          }
      }
  </script>
</body>
</html>
